export function localGet(key) {
    const value = window.localStorage.getItem(key)

    try {
        return JSON.parse(window.localStorage.getItem(key))
    } catch (error) {
        return value
    }
}

export function localSet(key, value) {
    try {
        // 确保 localStorage 支持
        if (window.localStorage) {
            // 正确使用 setItem 方法
            console.log('setValue',key,value)
            window.localStorage.setItem(key, JSON.stringify(value))
            console.log('数据存储成功');
        } else {
            console.log('浏览器不支持 localStorage');
        }
    } catch (error) {
        console.error('存储数据时发生错误:', error);
    }

    //window.localStorage.setItem(key, value)
}

export function localRemove(key) {
    window.localStorage.removeItem(key)
}

export const pathMap = {
    index: '首页',
    login: '登录',
    add: '添加商品'
}